import { CoolCommException } from '@cool-midway/core';
import { Rule, RuleType } from '@midwayjs/validate';

/**
 * 缴纳质保金DTO
 */
export class PayDepositDTO {
  @Rule(
    RuleType.number()
      .required()
      .min(0.01)
      .error(new CoolCommException('缴纳金额不能为空且需大于0'))
  )
  amount: number;

  @Rule(
    RuleType.string()
      .optional()
      .max(50)
      .error(new CoolCommException('支付方式不能超过50个字符'))
  )
  payMethod?: string;

  @Rule(
    RuleType.string()
      .optional()
      .max(500)
      .error(new CoolCommException('备注不能超过500个字符'))
  )
  remark?: string;
}

/**
 * 退还质保金DTO
 */
export class RefundDepositDTO {
  @Rule(
    RuleType.number()
      .required()
      .min(0.01)
      .error(new CoolCommException('退还金额不能为空且需大于0'))
  )
  amount: number;

  @Rule(
    RuleType.string()
      .optional()
      .max(500)
      .error(new CoolCommException('备注不能超过500个字符'))
  )
  remark?: string;
}

/**
 * 扣除质保金DTO（管理员操作）
 */
export class DeductDepositDTO {
  @Rule(
    RuleType.number()
      .required()
      .error(new CoolCommException('服务人员ID不能为空'))
  )
  providerId: number;

  @Rule(
    RuleType.number()
      .required()
      .min(0.01)
      .error(new CoolCommException('扣除金额不能为空且需大于0'))
  )
  amount: number;

  @Rule(
    RuleType.string()
      .required()
      .max(500)
      .error(new CoolCommException('扣除原因不能为空且不能超过500个字符'))
  )
  remark: string;
}

/**
 * 支付回调DTO
 */
export class DepositPayCallbackDTO {
  @Rule(
    RuleType.string()
      .required()
      .error(new CoolCommException('订单号不能为空'))
  )
  orderNo: string;

  @Rule(
    RuleType.string()
      .required()
      .error(new CoolCommException('第三方交易流水号不能为空'))
  )
  transactionId: string;
}

/**
 * 质保金记录查询DTO
 */
export class DepositRecordPageDTO {
  @Rule(RuleType.string().optional())
  operationType?: string;

  @Rule(RuleType.number().optional())
  status?: number;

  @Rule(RuleType.number().default(1))
  page?: number;

  @Rule(RuleType.number().default(20))
  size?: number;
}

